<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
	#res{width:200px;height:200px;border:solid 1px blue;}

	</style>
</head>
<body>
	<!-- 同源策略 -->

	<!-- localhost/7.html
	
	localhost/7.php
	
	
	http://www.baiudu.com
	https://www.taoba.com
	file:///7.php -->

	<button id='but'>服务器返回的结果</button>

	<div id='res'></div>

	<script type="text/javascript">
	var but = document.getElementById('but');

	var res = document.getElementById('res');

	but.onclick = function()
	{
		var x = new XMLHttpRequest;

		x.onreadystatechange = function()
		{
			if(x.readyState == 4 && x.status == 200)
			{
				res.innerHTML = x.responseText;
			}
		}

		x.open('GET','7.php',true);
		// x.open('GET','5-1.html',true);
		//x.open('GET','5-1.xml',true);

		x.send();
	}


	</script>
</body>
</html>